package com.ruoyi.bussiness.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bussiness.domain.SftDailyCheck;
import com.ruoyi.bussiness.service.ISftDailyCheckService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 日检信息Controller
 * 
 * @author ruoyi
 * @date 2023-11-12
 */
@Controller
@RequestMapping("/bussiness/checkD")
public class SftDailyCheckController extends BaseController
{
    private String prefix = "bussiness/checkD";

    @Autowired
    private ISftDailyCheckService sftDailyCheckService;

    @RequiresPermissions("bussiness:checkD:view")
    @GetMapping()
    public String checkD()
    {
        return prefix + "/checkD";
    }

    /**
     * 查询日检信息列表
     */
    @RequiresPermissions("bussiness:checkD:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SftDailyCheck sftDailyCheck)
    {
        startPage();
        List<SftDailyCheck> list = sftDailyCheckService.selectSftDailyCheckList(sftDailyCheck);
        return getDataTable(list);
    }

    /**
     * 导出日检信息列表
     */
    @RequiresPermissions("bussiness:checkD:export")
    @Log(title = "日检信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SftDailyCheck sftDailyCheck)
    {
        List<SftDailyCheck> list = sftDailyCheckService.selectSftDailyCheckList(sftDailyCheck);
        ExcelUtil<SftDailyCheck> util = new ExcelUtil<SftDailyCheck>(SftDailyCheck.class);
        return util.exportExcel(list, "日检信息数据");
    }

    /**
     * 新增日检信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存日检信息
     */
    @RequiresPermissions("bussiness:checkD:add")
    @Log(title = "日检信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SftDailyCheck sftDailyCheck)
    {
        return toAjax(sftDailyCheckService.insertSftDailyCheck(sftDailyCheck));
    }

    /**
     * 修改日检信息
     */
    @RequiresPermissions("bussiness:checkD:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        SftDailyCheck sftDailyCheck = sftDailyCheckService.selectSftDailyCheckById(id);
        mmap.put("sftDailyCheck", sftDailyCheck);
        return prefix + "/edit";
    }

    /**
     * 修改保存日检信息
     */
    @RequiresPermissions("bussiness:checkD:edit")
    @Log(title = "日检信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SftDailyCheck sftDailyCheck)
    {
        return toAjax(sftDailyCheckService.updateSftDailyCheck(sftDailyCheck));
    }

    /**
     * 删除日检信息
     */
    @RequiresPermissions("bussiness:checkD:remove")
    @Log(title = "日检信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sftDailyCheckService.deleteSftDailyCheckByIds(ids));
    }
}
